projectName=test-cicd-docker
env=online
vendor=${BUILD_NUMBER}
oldVendor=${BUILD_NUMBER} -1
outPort=8080
targetPort=8080
cd /usr/local/jars

docker stop $(docker ps -a | grep "$projectName"_"$oldVendor" | awk '{print $1}')

docker build -t $projectName:$vendor .

docker run -d --name "$projectName"_"$vendor" -e SPRING_PROFILES_ACTIVE="$env" -p $outPort:$targetPort $projectName:$vendor


